#-------------------------------------------------------------------------------
# Name:        Search_file
# Purpose:
#
# Author:      John
#
# Created:     11/01/2014
# Copyright:   (c) John 2014
# Licence:     <GPL3>
#-------------------------------------------------------------------------------
# import read_write as rw
import cmd
import readline
import pysnooper
import time
import os


class everything_shell(cmd.Cmd):
    intro  = 'Welcome to the EXCEL shell.   Type help or ? to list commands.\n'
    prompt = 'everything> '

    def default(self, arg):
        info=r'Error command'
        print(info)

    def precmd(self,arg):
        print('')
        print('>> %s'%(arg))
        readline.write_history_file(config.hisfile)
        return arg 

    def postcmd(self, stop, line):
        print('')
        return stop
    
    def do_updatedb(self, arg):
        with open('dirs') as f:
            for root_dir in f:
                get_fileinfolist_of_root_dir(root_dir, update_md5=False)

    def do_updatedb_md5sum(self, arg):
        with open('dirs') as f:
            for root_dir in f:
                get_fileinfolist_of_root_dir(root_dir, update_md5=True)
    
    def do_search(self, arg):
        pass

    def do_exit(self,arg):
        readline.write_history_file(config.hisfile)
        return True

if __name__ == '__main__':
    cur_dir = os.getcwd()
    everything_shell().cmdloop()
    os.chdir(cur_dir)
